package com.example.common.utils;

import android.text.TextUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
    public static final String DEFAULT_DATE_YS = "yyyy-MM-dd HH:mm:ss";

    public static String format(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }

    public static String formatStringData(String time, String format) {
        if (TextUtils.isEmpty(time)) {
            return "";
        }
        return format(new Date(time), format);
    }

    public static String formatLongData(Long time, String format) {
        if (time==null) {
            return "";
        }
        return format(new Date(time), format);
    }

    public static String getCurrentDate() {
        return format(new Date(), DEFAULT_DATE_YS);
    }

}
